package com.mlnx.analysis.service.iml;

import com.mlnx.analysis.service.EcgAnalysisService;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;


/**
 * Created by amanda.shan on 2020/4/8.
 */
public class EcgAnalysisServiceFactory {

    private static EcgAnalysisServiceFactory instance = new EcgAnalysisServiceFactory();

    private Map<String, EcgAnalysisService> ecgAnalysisServiceMap = new ConcurrentHashMap<>();


    public static EcgAnalysisServiceFactory getInstance() {
        return instance;
    }

    public synchronized EcgAnalysisService getEcgAnalysisService(String deviceId, byte[] gpu8AcId) {

        EcgAnalysisService ecgAnalysisService = ecgAnalysisServiceMap.get(deviceId);
        if (ecgAnalysisService == null) {
            ecgAnalysisService = new EcgAnalysisServiceIml(deviceId, gpu8AcId);
            ecgAnalysisService.init();
            ecgAnalysisServiceMap.put(deviceId, ecgAnalysisService);
        }

        return ecgAnalysisService;
    }
}
